package com.hyou.springboot.validator.constraints;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.apache.commons.lang3.StringUtils;

import com.hyou.springboot.annotation.validator.Mobile;

/**
 * 手机号格式校验实现类
 * 
 * @author FengChangshuo
 * @version 1.0.0 2018-11-15 16:39:53 初始创建
 */
public class MobileValidator implements ConstraintValidator<Mobile, String> {

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (StringUtils.isBlank(value)) {
            return true;
        }
        
        return value.matches("[1][0-9]{10}");
    }
    
}
